package com.leoman.plz_p.adapter;

import android.content.Context;
import android.graphics.Color;

import com.leoman.plz_p.R;
import com.leoman.plz_p.module.bean.AnswerBean;

import java.util.List;

import cn.com.corelib.utils.adapter.BaseAdapterHelper;
import cn.com.corelib.utils.adapter.normal.QuickAdapter;

/**
 * Created by guoh on 2018/7/7.
 */
public class AnswerAdapter extends QuickAdapter<AnswerBean> {

    public void setAnswers(List<String> answers) {
        this.answers = answers;
    }

    private List<String> answers;

    public boolean isHasAnswered() { return hasAnswered; }

    public void setIsNotNormalExam(boolean b){
        this.isNotNormalExam =b;
    }

    public void setHasAnswered(boolean hasAnswered) {
        this.hasAnswered = hasAnswered;
    }

    private boolean hasAnswered;

    private boolean isNotNormalExam =true;

    public AnswerAdapter(Context context) {
        super(context, R.layout.item_answer);
    }

    @Override
    protected void convert(BaseAdapterHelper helper, AnswerBean item, int position) {
        helper.setText(R.id.tv_answer,item.getContent());
        //正常考试
        if (position==0){
            helper.setText(R.id.tv_position,"A");
        }
        if (position==1){
            helper.setText(R.id.tv_position,"B");
        }
        if (position==2){
            helper.setText(R.id.tv_position,"C");
        }
        if (position==3){
            helper.setText(R.id.tv_position,"D");
        }
        if (position==4){
            helper.setText(R.id.tv_position,"E");
        }
        if (position==5){
            helper.setText(R.id.tv_position,"F");
        }
        helper.setBackgroundRes(R.id.tv_position,R.mipmap.icon_noraml_status);
        helper.setTextColor(R.id.tv_answer, Color.parseColor("#000000"));


        if (!isNotNormalExam){
            //正常考试不判断对错
            if (item.getAnswerRight()!=null){
                helper.setBackgroundRes(R.id.tv_position, R.mipmap.icon_question_answer_normal);
            }
        }else {
            if (item.getAnswerRight()!=null){
                if (item.getAnswerRight()){
                    //答对
                    helper.setBackgroundRes(R.id.tv_position,R.mipmap.icon_question_answer_right);
                    helper.setText(R.id.tv_position,"");
                    helper.setTextColor(R.id.tv_answer,Color.parseColor("#5ab5f9"));
                }else {
                    //答错
                    helper.setBackgroundRes(R.id.tv_position,R.mipmap.icon_question_answer_error);
                    helper.setText(R.id.tv_position,"");
                    helper.setTextColor(R.id.tv_answer, Color.parseColor("#fc0200"));
                }
            }

        }

        if (hasAnswered&&isNotNormalExam) {
            if (item.isRight()) {
                helper.setBackgroundRes(R.id.tv_position, R.mipmap.icon_question_answer_right);
                helper.setText(R.id.tv_position, "");
                helper.setTextColor(R.id.tv_answer,Color.parseColor("#5ab5f9"));
            }
        }

    }
}
